feat(jvm): Add multi-certificate and system truststore support for CAcerts#6441
feat(jvm): Add multi-certificate and system truststore support for CAcerts#6441squakez merged 5 commits intoapache:mainfrom
Conversation
|
✔️ Unit test coverage report - coverage increased from 60.8% to 61.2% (+0.4%) |
squakez
left a comment
There was a problem hiding this comment.
Great works, thanks for taking care. However, we need to make a few changes to make it more consistent and secure.
- The passwords must be specified by final user. What we need to do is to provide some mechanism to make sure we correctly associate the parameter file with the parameter passwords (for example, implementing an internal simple struct to have file/passwordFile and referring it in the object like done in Keda trait).
- Make the user provide the path to the existing trusstore to merge. There is no easy way to make it sure we identify the valid truststore the final user wants to use (it also depends on the base image chosen). We can add a parameter for that and just use it straight for merge.
- If we're going for a list of cacerts, then, we need to deprecate the existing single cacert file/password parameter.
…pport with secure password handling
|
@squakez thanks for the review and the feedback. i'll keep this in mind. Need input on user provided paths (like I was not able to run the E2E test locally, not sure but my local setup due to Maven dependency download issues during integration builds. |
|
✔️ Unit test coverage report - coverage increased from 60% to 61.2% (+1.2%) |
|
✔️ Unit test coverage report - coverage increased from 59.9% to 61.2% (+1.3%) |
squakez
left a comment
There was a problem hiding this comment.
I think we have it. Only some doubts around the usage of the base trustore password.
|
@squakez Thanks! i resonate with you, preserving the base truststore password will result in a much more simplified implementation i have made changes to reflect the same. |
|
✔️ Unit test coverage report - coverage increased from 60% to 61.2% (+1.2%) |
…sswordPath and cleanup tests
|
I have implemented a simplified approach incorporating your suggestion. This will make the whole process more simpler (I hope so) and explicit. Added explicit Base truststore handling: When both base-truststore and truststore-password-path are set, we:
Removed per-certificate passwordPath from CACertConfig, only the truststore needs password. |
|
✔️ Unit test coverage report - coverage increased from 60.1% to 61.2% (+1.1%) |
|
@squakez thanks a lot for your thoughtful guidance and review! It really helped me think better in terms of user experience. |
This PR improves the JVM trait's CA certificate handling to address the issues reported in #6432.
Features
ca-certificatesfield accepts a list ofCACertConfig{certPath}entries for importing multiple PEM certificatestruststore-password-pathfield for specifying the output truststore password (PEM certificates don't have passwords, only the truststore does)base-truststorefield allows using an existing truststore (e.g., JDK cacerts) as the starting point for adding custom certificatestruststore-password-path→base-truststore.password-path→ legacyca-cert-passwordca-certandca-cert-passwordare deprecated in favor of the new structured fieldsFix
-storepass:file(keytool), never hardcodedchangeitpassword - users must explicitly provide password files for securityExamples
Single Certificate
Multiple Certificates
kamel run MyRoute.java \ -t mount.configs=secret:ca1 \ -t mount.configs=secret:ca2 \ -t mount.configs=secret:truststore-pass \ -t jvm.ca-certificates[0].cert-path=/etc/camel/conf.d/_secrets/ca1/ca.crt \ -t jvm.ca-certificates[1].cert-path=/etc/camel/conf.d/_secrets/ca2/ca.crt \ -t jvm.truststore-password-path=/etc/camel/conf.d/_secrets/truststore-pass/passwordWith Base Truststore (preserve JDK public CAs)
kamel run MyRoute.java \ -t mount.configs=secret:my-ca \ -t mount.configs=secret:cacerts-pass \ -t jvm.base-truststore.truststore-path=/opt/java/openjdk/lib/security/cacerts \ -t jvm.base-truststore.password-path=/etc/camel/conf.d/_secrets/cacerts-pass/password \ -t jvm.ca-certificates[0].cert-path=/etc/camel/conf.d/_secrets/my-ca/ca.crtNote: When using base-truststore, you can optionally provide truststore-password-path to set a different password for the output truststore. If not provided, the base truststore password is used.
Deprecated Syntax (backward compatible)
kamel run MyRoute.java \ -t mount.configs=secret:my-ca \ -t mount.configs=secret:my-password \ -t jvm.ca-cert=/etc/camel/conf.d/_secrets/my-ca/ca.crt \ -t jvm.ca-cert-password=/etc/camel/conf.d/_secrets/my-password/password